package org.foreveross.taluo.infra;

import java.util.List;

import org.apache.log4j.Logger;
import org.foreveross.que.infra.JobTransTaluoRepository;
import org.foreveross.taluo.entity.AcUserEntity;

import com.dayatang.domain.InstanceFactory;


public class JobTransTaluoUsers extends java.util.TimerTask {
	protected static Logger logger = Logger.getLogger(JobTransTaluoUsers.class);
	ITaluoBaseRepository taluoBaseRepository ; 
	
	JobTransTaluoRepository baseRepository ;
	

	@Override
	public void run() {
		 try {
			 logger.info("transfers users begin!!");
		if(baseRepository==null){
			Thread.sleep(8000);
			baseRepository = InstanceFactory.getInstance(JobTransTaluoRepository.class,"jobTransTaluoRepositoryImpl");
		}
		 List<AcUserEntity> acUsers = taluoBaseRepository.findAcUsers();
		 baseRepository.transUsers(acUsers);
		 } catch (Exception e) {
				e.printStackTrace();
		}finally{
			 logger.info("transfers users end!!");
		}
		
	}
	
	

	public ITaluoBaseRepository getTaluoBaseRepository() {
		return taluoBaseRepository;
	}

	public void setTaluoBaseRepository(ITaluoBaseRepository taluoBaseRepository) {
		this.taluoBaseRepository = taluoBaseRepository;
	}
}
